home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 5359 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  63 lines

  1. Path: jupiter.sun.csd.unb.ca!dwoo
  2. From: dwoo@jupiter.sun.csd.unb.ca (Dennis K. C. Woo)
  3. Newsgroups: comp.lang.c
  4. Subject: A question for the C experts..
  5. Date: 12 Feb 1996 13:17:51 GMT
  6. Organization: University of New Brunswick, Fredericton, NB, Canada
  7. Message-ID: <4fnelv$dvp@sol.sun.csd.unb.ca>
  8. NNTP-Posting-Host: jupiter-alt3.unb.ca
  9.  
  10. Hi Experts, 
  11.  
  12. In the following code fragment, a sturcture is defined as COMPLEX. The 
  13. argument var1 is defined as a 32-bit word. The lines that marked as 
  14. "offending line" caused the Watcom compiler to complain that "expression 
  15. for '->' must be a pointer to structure or union". However, the variable 
  16. v1 is already declared as a pointer to COMPLEX...why is wrong? I had 
  17. tried to change the COMPLEX declaration to double and everything worked 
  18. fine. 
  19.  
  20. /*
  21.  *  VBDLL32.C
  22.  */
  23. #include <stdio.h>
  24. #include <windows.h>    /* required for all Windows applications */
  25. typedef struct { double Real ; double Imag ; } COMPLEX ;
  26.  
  27. long FAR PASCAL Add3( DWORD var1 )
  28. {
  29.     int i ;
  30.     COMPLEX far *v1 ;
  31.  
  32.     v1 = MK_FP32((void *)var1);
  33.     for( i=0; i<5 ; i++ )
  34.     {
  35.         v1[i]->Real *= 2 ;   // offending line
  36.         v1[i]->Imag *= 2 ;   // offending line
  37.     }
  38.     return( (long)1 );
  39.  
  40. }
  41.  
  42. #pragma off (unreferenced);
  43. int PASCAL WinMain(HANDLE hInstance, HANDLE x1, LPSTR lpCmdLine, int x2)
  44. #pragma on (unreferenced);
  45. {
  46.     DefineDLLEntry( 1, (void *) Add3, DLL_DWORD, DLL_ENDLIST );
  47.     return( 1 );
  48. }
  49.  
  50.  
  51. Thanks a million.
  52.  
  53. Dennis
  54. *****************************************************************
  55. *  Dennis Woo              Department of Mechanical Engineering *
  56. *  E-mail: dwoo@unb.ca     University of New Brunswick          *
  57. *  Office Tel: (506) 447-3076                 --------  __o     *       
  58. *  Voice mail: (506) 453-0614                -------  _`\<,_    *
  59. *  FAX       : (506) 453-5025               -------  (*)/ (*)   *
  60. *****************************************************************    
  61.  
  62.  
  63.